<?php defined('IN_ADMIN') or exit('Access Denied!'); ?>

<form action="/admin/hotel_menu/save/<?=intval($shop_id);?>" method="post" id="myform">
  <input type="hidden" name="method" value="<?=$method;?>" />
  <input type="hidden" name="menu_id" value="<?=i($data['menu_id']);?>" />
  <input type="hidden" name="ordnum" value="<?=i($data['ordnum']);?>" />
  <div class="pad-10">
    <div class="col-tab">
      <ul class="tabBut cu-li" id="tab_setting">
        <li id="tab_setting_1" class="on">基本信息</li>
      </ul>
      <div id="show_div_1" class="content pad-10">
        <table width="100%" id="customize_config" class="table_form">
          <tbody id="customize_config_0">
            <tr>
              <td width="120">套系名称：</td>
              <td class="y-bg"><input type="text" class="input-text" name="name" id="name" size="50" value="<?=h($data['name']);?>"/></td>
            </tr>
            <tr>
              <td width="120">价格：</td>
              <td class="y-bg"><input type="text" class="input-text" name="price" id="price" size="30" value="<?=h($data['price']);?>"/>
                &nbsp;&nbsp;&nbsp;&nbsp;<font color="gray">元/桌</font></td>
            </tr>
            <tr>
              <td width="100">酒店赠送：</td>
              <td><textarea id="extra" name="extra" cols="50" rows="4"><?=h($data['extra']);?></textarea></td>
            </tr>
            <tr>
              <td colspan="2"><fieldset>
                  <legend>菜单</legend>
                  <input type="button" onclick="add_menu()" value="添加新套系" class="button">
                  &nbsp; 每行填写一个菜品。也可以<a href="#" onclick="del_menu()"><u>删除最后一套菜单</u></a>
                  <table width="100%" class="table_form" id="menu_table">
                  <?php
                    if(!isset($data['menus'][0])) $data['menus'][0] = '';
                    foreach($data['menus'] as $key => $var){
                  ?>
                    <tr>
                      <td width="100"><?=chr(ord('A') + $key); ?>套：</td>
                      <td><textarea id="menus_<?=$key; ?>" name="menus[]" cols="50" rows="4"><?=h($var); ?></textarea></td>
                    </tr>
                  <?php
                    }
                  ?>
                  </table>
                </fieldset></td>
            </tr>
          </tbody>
        </table>
      </div>
      <div class="bk15"></div>
      <input name="dosubmit" id="dosubmit" type="submit" value="提交" class="dialog">
    </div>
  </div>
</form>
<script type="text/javascript">
function add_menu(){
    var idx = $("#menu_table").find("tr").size() + 1;
    if(idx > 5){
        window.top.art.dialog({content:"最多填写5套菜品",lock:true,width:'200',height:'50'}, function(){this.close();});
    }else{
        var html = '<tr><td width="100">' +String.fromCharCode(64 + idx)+ '套：</td><td><textarea id="menus_' +idx+ '" name="menus[]" cols="50" rows="4"></textarea></td></tr>';
        $("#menu_table").append(html);
    }
}
function del_menu(){
    var cnt = $("#menu_table").find("tr").size();
    if(cnt == 1){
        window.top.art.dialog({content:"至少保留一套菜单",lock:true,width:'200',height:'50'}, function(){this.close();});
    }else{
        $("#menu_table").find("tr:last").remove();
    }
}
$(document).ready(function(){
    $.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'200',height:'50'}, function(){this.close();$(obj).focus();})}});
    $("#name").formValidator({onshow:"请输入菜牌名称",onfocus:"请输入菜牌名称"}).inputValidator({min:1,onerror:"菜牌名称没有填写"});
});
</script>
